/********************************************************************
Name: Comparing Trends Across Control Groups (Figure A6)
Author: Dan Thompson
Date: September 2021
Description: 

********************************************************************/

clear all
set matsize 11000
set maxvar 15000
gl path = "~/Dropbox/Mariel Effects"

* Add variables to the analysis data that flag the different control groups
use if year<1980 using "$path/Replication/data/county_analysis_data.dta", clear
gen flag1 = treated==1
gen flag2 = state=="florida" & treated!=1
gen flag3 = rank<=252 & treated!=1
gen flag4 = treated!=1
tempfile data
save `data'

* Prepare the trends for each comparison group
qui forval g=1/4 {
	use if flag`g'==1 using `data', clear
	collapse rep_vs, by(year)
	gen group = `g'
	if `g'==1 tempfile output
	else append using `output'
	save `output', replace
}

* Plot the trends for each comparison group
replace rep_vs = rep_vs*100
twoway (connected rep_vs year if group==2, mc(gs14) lc(gs14) lp(dash)) ///
	(connected rep_vs year if group==3, mc(gs10) lc(gs10) lp(dash)) ///
	(connected rep_vs year if group==4, mc(gs6) lc(gs6) lp(dash)) ///
	(connected rep_vs year if group==1, mc(gs2) lc(gs2)), ///
	legend(order(4 "Miami-Dade" 1 "Florida" ///
		2 "Top 250 Pop" 3 "All Counties")) ///
	xti("Year") yti("Rep Pres Vote Share (%)") ///
	graphregion(color(white))
graph export "$path/Replication/output/trend_comparison.pdf", replace
